﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GSLMS.Services.Interface;
using GSLMS.Entity;
using GSLMS.Entity.DTO;
using GSLMS.DAL;
namespace GSLMS.Services
{
	/// <summary>
	/// 此层为服务层，已经继承了父类BaseService,已经定义好方法请查看BaseService类；若需要自定义方法请在此层增加并在数据层及接口层定义相关的方法
	/// </summary>
	public partial class SSYS_EMP: BaseService<TB_SYS_EMP>, ISYS_EMP
	{
		private static readonly GSLMS.DAL.Oracle.SYS_EMP dal = new GSLMS.DAL.Oracle.SYS_EMP();
		public override BaseDAL<TB_SYS_EMP> DAL
		{
			get { return dal; }
		}

        /// <summary>
		///  增加一条数据,-1用户名已经存在，1成功，0失败
		/// </summary>
        public  int AddEmp(GSLMS.Entity.TB_SYS_EMP model)
        {
            return dal.AddEmp(model);
        }
        /// <summary>
        ///  更新一条数据,-1用户名已经存在，1成功，0失败
		/// </summary>
        public  int UpdateEmp(GSLMS.Entity.TB_SYS_EMP model)
        {
            return dal.UpdateEmp(model);
        }

        /// <summary>
        /// 解冻用户/冻结用户
        /// </summary>
        /// <param name="ID">职员记录ID</param>
        /// <param name="userStatus">用户状态，1解冻，0冻结</param>
        /// <returns></returns>
        public bool LockOrUnLockUser(long ID, int userStatus)
        {
            return dal.LockOrUnLockUser(ID, userStatus);
        }

        /// <summary>
        /// 修改登录密码
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="pwd">原密码</param>
        /// <param name="newPwd">新密码</param>
        /// <returns>-1用户不存在,-2原密码输入不正确，1成功，0失败</returns>
        public int UpdatePwd(string userName, string pwd, string newPwd)
        {
            return dal.UpdatePwd(userName, pwd, newPwd);
        }

        /// <summary>
        /// 修改登录密码
        /// </summary>
        /// <param name="ID">职员记录ID</param>
        /// <param name="newPwd">MD5新密码</param>
        /// <returns>-1用户不存在,1成功，0失败</returns>
        public int ResetPwd(long ID, string newPwd)
        {
            return dal.ResetPwd(ID, newPwd);
        }

        /// <summary>
        /// 验证用户登录
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="pwd">MD5加密密码</param>
        /// <returns></returns>
        public GSLMS.Entity.TB_SYS_EMP CheckLogin(string userName, string pwd)
        {
            return dal.CheckLogin(userName, pwd);
        }

        /// <summary>
        /// 更新最新登录时间
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns></returns>
        public bool UpdateLastLoginDate(string userName)
        {
            return dal.UpdateLastLoginDate(userName);
        }

        /// <summary>
        /// 通过用户名获取用户信息
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns></returns>
        public GSLMS.Entity.TB_SYS_EMP GetByUserName(string userName)
        {
            return dal.GetByUserName(userName);
        }

        /// <summary>
        /// 提取所有业务员信息,包含已经离职、休假的业务员
        /// </summary>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetSalesAllList()
        {
            return dal.GetSalesAllList();
        }

        /// <summary>
        /// 提取所有有效业务员信息,不包含已经离职业务员
        /// </summary>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetSalesEffList()
        {
            return dal.GetSalesEffList();
        }

        /// <summary>
        /// 提取所有用户信息,包含已经离职和休假的用户
        /// </summary>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetUserAllList()
        {
            return dal.GetUserAllList() ?? new List<TB_SYS_EMP>();
        }

        /// <summary>
        /// 提取所有用户信息,不包含已经离职用户
        /// </summary>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetUserEffList()
        {
            return dal.GetUserEffList() ?? new List<TB_SYS_EMP>();
        }

        /// <summary>
        /// 提取所有用户信息,不包含已经离职、已经休假的用户
        /// </summary>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetUserWorkList()
        {
            return dal.GetUserWorkList() ?? new List<TB_SYS_EMP>();
        }

        /// <summary>
        /// 提取拥有某种权限的所有用户信息,包含已经离职、已经休假的用户
        /// </summary>
        /// <param name="modelID">模块记录ID，如：Employee等</param>
        /// <param name="operType">操作标识符，如：ADD,ADU等</param>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetUserPrivAllList(string modelID, string operType)
        {
            return dal.GetUserPrivAllList(modelID, operType) ?? new List<TB_SYS_EMP>();
        }

        /// <summary>
        /// 提取拥有某种权限的所有用户信息,不包含已经离职的用户
        /// </summary>
        /// <param name="modelID">模块记录ID，如：Employee等</param>
        /// <param name="operType">操作标识符，如：ADD,ADU等</param>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetUserPrivEffList(string modelID, string operType)
        {
            return dal.GetUserPrivEffList(modelID, operType) ?? new List<TB_SYS_EMP>();
        }

        /// <summary>
        /// 提取拥有某种权限的所有用户信息,不包含已经离职、已经休假的用户
        /// </summary>
        /// <param name="modelID">模块记录ID，如：Employee等</param>
        /// <param name="operType">操作标识符，如：ADD,ADU等</param>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetUserPrivWorkList(string modelID, string operType)
        {
            return dal.GetUserPrivWorkList(modelID, operType);
        }

        /// <summary>
        /// 提取所有职员信息
        /// </summary>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetAllEmp()
        {
            return dal.GetAllEmp();
        }

        /// <summary>
        /// 提取所有未离职员信息
        /// </summary>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetEffAllEmp()
        {
            return dal.GetEffAllEmp();
        }

        /// <summary>
        /// 提取有风控审批权限的用户信息
        /// </summary>
        /// <param name="actionBy">查询人或是分配人，会提取同等级及其下级有风控审批权限的用户信息</param>
        /// <returns></returns>
        public List<GSLMS.Entity.TB_SYS_EMP> GetRiskAuditUserList(string actionBy)
        {
            return dal.GetRiskAuditUserList(actionBy);
        }
	}
}
